<script setup lang="ts">

import { onMounted, ref } from "vue";

const styleClass = ref(null)
// 定义props ：简单的模块，抽象成props
const props = defineProps({
    // 活动id
    activeId: {
        type: Number,
        //required: true // 如果希望活动 id 是必传的，可以添加 required: true  
    },
    // 主标题
    title: {
        type: String
    },
    // 副标题
    subTitle: {
        type: String
    },
    // 活动详情超链接
    // activeUrl: {
    //     type: String
    // },
    // 进行状态:进行中，已结束
    state: {
        type: String
    }

})
// 在组件挂载时执行逻辑

onMounted(() => {
  // 根据条件判断赋值 styleClass
//   在 defineProps 中声明的属性需要通过 props 访问，而不是直接引用。因此，你应该使用 props.state 而不是 state。
if (props.state === '进行中') {
    styleClass.value = 'fav-state bluebg';
  } else {
    // 其他条件下的样式类赋值
    styleClass.value = 'fav-state graybg';
  }
})
</script>
<template>
    <div class="list-item top-list-item">
        <div class="fav-img">
            <slot />
        </div>
        <div class="fav-wrap">
            <div class="fav-title">{{ title }}</div>
            <div class="fav-con">{{ subTitle }}</div>
            <!-- <div class="fav-url"><button color="primary" type="button" class="ant-btn ant-btn-default ant-btn-block">
                    <a :href="activeUrl">
                        <span>查看活动</span>
                    </a>
                </button>
            </div> -->
            <RouterLink :to="{ name: 'activitydetails', params: { activityId: activeId } }">
                
                <div class="fav-url"><button color="primary" type="button" class="ant-btn ant-btn-default ant-btn-block">
                        <a href="">
                            <span>查看活动</span>
                        </a>
                    </button>
                </div>
            </RouterLink>
            <div :class="styleClass">
                <p>活动<br>{{ state }}</p>
            </div>
        </div>
    </div>
</template>
<style scoped lang="scss">
.activity-index-wrap {
    position: relative;
    font-family: Arial, PingFang-SC-Regular, Microsoft yahei, "\5FAE\8F6F\96C5\9ED1", Hiragino Sans GB, tahoma, STHeiTi, "\5B8B\4F53", sans-serif;
    background: #f4f4f5;
}

.activity-index-wrap .main-content {
    min-height: 300px;
    width: 1200px;
    margin: 0 auto;
}

.activity-list-wrap {
    width: 1200px;
    margin: 60px 0 30px;
}

.activity-list-wrap .oh-wrap {
    width: 1218px;
}

.activity-list-wrap .list-item.top-list-item {
    width: 1198px;
    height: 322px;
    padding-left: 712px;
    margin: 0 18px 30px 0;
    cursor: default;
}

.activity-list-wrap .list-item {
    position: relative;
    float: left;
    width: 386px;
    height: 326px;
    margin: 0 18px 20px 0;
    background-color: #fff;
    cursor: pointer;
    border: 1px solid #f2f3f5;
}

.activity-list-wrap .list-item.top-list-item .fav-img {
    width: 680px;
    height: 320px;
    position: absolute;
    left: 0;
    top: 0;
}

.activity-list-wrap .list-item.top-list-item .fav-wrap {
    padding: 0 20px 0 0;
}

.fav-title {
    font-size: 24px;
    line-height: 25px;
    padding: 40px 0;
}

.activity-list-wrap .list-item {
    font-size: 16px;
    line-height: 20px;
    color: #1b2939;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    padding-top: 18px;
    padding-bottom: 8px;
}

.activity-list-wrap .list-item.top-list-item .fav-url {
    padding-bottom: 26px;
}

.fav-url .ant-btn {
    width: 160px;
    height: 42px;
    background: #fabe00;
    color: #fff;
    font-size: 14px;
    border: none;
}

.ant-btn,
.ant-btn:active,
.ant-btn:focus {
    outline: 0;
}

.ant-btn {
    line-height: 1.5715;
    position: relative;
    display: inline-block;
    font-weight: 400;
    white-space: nowrap;
    text-align: center;
    background-image: none;
    box-shadow: 0 2px 0 rgba(0, 0, 0, .015);
    cursor: pointer;
    transition: all .3s cubic-bezier(.645, .045, .355, 1);
    user-select: none;
    touch-action: manipulation;
    height: 32px;
    padding: 4px 15px;
    font-size: 14px;
    border-radius: 2px;
    color: rgba(0, 0, 0, .85);
    border: 1px solid #d9d9d9;
    background: #fff;
}

.fav-state {
    position: absolute;
    top: 0;
    left: 0;
    width: 80px;
    height: 42px;
    line-height: 20px;
    text-align: center;
    color: #fff;
}

.activity-list-wrap .list-item .fav-state.bluebg {
    background: #377aea;
}

.graybg {
    background: #3d3d3d;
}

.activity-list-wrap .list-item .fav-con {
    height: 40px;
    font-size: 14px;
    color: #939a9f;
}
</style>